﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using MachineQA.Model;

namespace MachineQA
{
    /// <summary>
    /// Interaction logic for SiteManagementDialog.xaml
    /// </summary>
    public partial class SiteManagementDialog : Window
    {
        public SiteManagementDialog()
        {
            InitializeComponent();
        }

        private void CloseButton_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void NewMachineNameBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            SaveButton.IsEnabled = true;
        }

        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            QADatabaseEntities context = new QADatabaseEntities();
            Location newLocation = new Location();
            newLocation.Name = "SRCC";
            context.AddToLocations(newLocation);
            context.SaveChanges();
            Machine newMachine = new Machine();
            newMachine.Name = NewMachineNameBox.Text;
            newMachine.Location = newLocation;
            context.AddToMachines(newMachine);
            context.SaveChanges();
        }

        private void SiteConfiguration_Loaded(object sender, RoutedEventArgs e)
        {

        }
    }
}
